<template>
  <div class="page">
    <navigation>{{ $t('提币地址') }}</navigation>
    <div v-if="list" class="list">
      <div v-for="(item, index) in list" :key="item.id" class="item" @click="gotoEdit(index)">
        <img class="icon" :src="downPath + item.icon" alt="">
        <div class="lab">{{ item.title }}</div>
        <div class="val">{{ item.coin_symbol }}</div>
        <i class="iconfont icon-jiantouarrow487"></i>
      </div>
    </div>
    <div v-else class="wujilu">
      <i class="iconfont icon-zanwuyituichudingdan"></i>
      <p>{{ $t('您还没有提币地址，快去创建吧！') }}</p>
    </div>
    <nuxt-link to="add_addr?type=add" class="menubtn">{{ $t('新建提币地址') }}</nuxt-link>
  </div>
</template>
<script>
import { mapState, mapActions } from 'vuex'
import storage from '@/utils/storage'
import navigation from '@/components/Navigation'
export default {
  components: { navigation },
  data () {
    return {
      list: null
    }
  },
  computed: {
    ...mapState({
      downPath: ({ imgBaseUrl }) => imgBaseUrl
    })
  },
  mounted () {
    this.getAddrList()
      .then((data) => {
        this.list = data.data
      })
      .catch((data) => {})
  },
  methods: {
    ...mapActions({
      getAddrList: 'user/getAddrList'
    }),
    gotoEdit (index) {
      storage.set('addrData', JSON.stringify(this.list[index]))
      this.$router.push({
        path: 'add_addr',
        query: {
          type: 'edit'
        }
      })
    }
  }
}
</script>
<style scoped>
.list {
  overflow: hidden;
  padding-bottom: 50px;
}
.item {
  position: relative;
  padding: 0 15px;
  line-height: 50px;
  height: 50px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.item:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 15px;
  right: 0;
  height: 0;
  border-bottom: 1px solid #eee;
}
.item .icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 15px;
}
.item .icon {
  position: static;
  flex-shrink: 0;
  margin-right: 10px;
  width: 32px;height: 32px;
}
.item .lab {
  flex-shrink: 0;
  font-size: 15px;
}
.item .val {
  flex-grow: 1;
  text-align: right;
  padding: 0 10px;
  font-size: 14px;
}
.menubtn {
  position: fixed;
  bottom: 0;
  left: 0;
  line-height: 40px;
  height: 40px;
  width: 100%;
  background: #1b8afe;
  text-align: center;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
}
.wujilu {
  width: 100%;
  float: left;
  text-align: center;
  margin: 100px 0;
}
.wujilu i {
  font-size: 70px;
  color: #c5c9d5;
}
.wujilu p {
  color: #828fa2;
  line-height: 30px;
}
</style>
